package com.hu.hutool.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author CazCen
 * @Date 2022/1/16 2:31
 */
@Configuration
@Data
public class OssConfig {

//    LTAI5tMyewsCYUvuX5qj4LkF
//            acObA4GPwQdHdIXQXQPqymiX3Tt47Q

    @Value("oss.file.bucketName")
    private String bucketName;

    @Value("oss.file.endpoint")
    private String endpoint;

    @Value("oss.file.accessKeyId")
    private String accessKeyId;

    @Value("oss.file.accessKeySecret")
    private String accessKeySecret;

    @Bean
    public OSS ossClient(){
        // Endpoint以成都为例。
        String endpoint = "oss-cn-shenzhen.aliyuncs.com";
        String accessKeyId = "LTAI5tMyewsCYUvuX5qj4LkF";
        String accessKeySecret = "acObA4GPwQdHdIXQXQPqymiX3Tt47Q";
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        return ossClient;
    }

}
